package com.forum.mapper.talk;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forum.pojo.talk.TalkPostsCommentReply;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Tsing
 * 聊吧论坛评论回复Mapper
 */
@Mapper
@Repository
public interface TalkPostsCommentReplyMapper extends BaseMapper<TalkPostsCommentReply> {

    /**
     * 分页获取指定的回复
     * @return List
     * @param page 当前页
     * @param commentId 评论Id
     * **/
    @Select("select id, comment_id, publisher_id, parent_user_id, content, create_time from talk_posts_comment_reply where comment_id=${commentId} limit ${page},10;")
    List<TalkPostsCommentReply> getReplyList(@Param("commentId") Integer commentId,@Param("page") Long page);

    /**
     * 统计上述语句的总量
     * @return Integer
     * @param commentId 评论Id
     * **/
    @Select("select count(*) from talk_posts_comment_reply where comment_id=${commentId};")
    Integer replyCount(@Param("commentId") Integer commentId);
}
